package C;

import java.util.*;

public class C44 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split("");
        System.out.println(getResult(s));
    }
    public static boolean getResult(String[] s) {
        String cur = "";
        LinkedList<String> stack = new LinkedList<>();
        for (int i=0;i<s.length;i++) {
            if (s[i].equals("(")||s[i].equals("[")||s[i].equals("{")) {
                stack.push(s[i]);
            } else if (!stack.isEmpty() && (s[i].equals(")")||s[i].equals("]")||s[i].equals("}"))) {
                if (s[i].equals(")") && stack.peek().equals("(")) {
                    stack.pop();
                } else if (s[i].equals(")") && stack.peek().equals("(")) {
                    stack.pop();
                } else if (s[i].equals(")") && stack.peek().equals("(")) {
                    stack.pop();
                } else {
                    return false;
                }
            }
            System.out.println(stack);
        }
        return stack.isEmpty();
    }
}
